<?php
/**
 * Created by PhpStorm.
 * User: dev
 * Date: 2018/8/7
 * Time: 10:46
 */

namespace App\Services\ApiServer\Response\Node;

use Illuminate\Support\Facades\Request;

/**
 * cam节点
 */
class CamNode extends BaseNode
{
    /*
     * 订单
     */
    private $nodeOrder;

    /*
     * rpc节点
     */
    private $nodeRpc;

    /**
     * 构造函数
     * CamNode constructor.
     */
    function __construct(){
        parent::__construct();
        $camNodeOrder = config('app.node.'.$this->blockDomain.'.cam_bibowallet_order_api');
        $camNodeRpc = config('app.node.'.$this->blockDomain.'.cam_bibowallet_rpc_api');
        //判断用户连接的节点(根据客户端传值进行判断)
        $header = Request::header();
        $this->nodeOrder = $camNodeOrder[0];
        $this->nodeRpc = $camNodeRpc[0];
    }

    /**
     * cam 钱包地址余额
     * @DateTime 2018-08-13
     * @version  [version]
     * @param   {string}
     * @param    [type]     $address  [description]
     * @param    [type]     $asset_id [description]
     * @return   [type]               [description]
     */
    public function getWalletBalance($address, $asset_id = null){
        $url = $this->nodeOrder.'/getaccountbalance/'.$asset_id.'/'.$address;
        $result = sendCurl($url, '', 'GET');
        if(!empty($result['balance'])){
            $return = $result['balance'];
        }
        return $return;
    }
}